package us.pigsoft.client;

import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.Shape;
import java.awt.geom.Ellipse2D;
import java.util.ArrayList;

public class Projectile {

	double x, y, width, height, speed, angle;
	Shape bulletShape;
	Color color;
	Rectangle bounds;
	static ArrayList<Projectile> projectiles = new ArrayList<Projectile>();
	
	public Projectile()
	{
		angle = 140;
		x = y = 0;
		speed = 25;
		width = height = 8;
		bulletShape = (Shape) new Ellipse2D.Double(0, 0, width, height);
		color = Color.RED;
		bounds = new Rectangle((int) width, (int) height);
		projectiles.add(this);
	}
	
	public Projectile(Player p)
	{
		this();
		x = p.x;
		y = p.y;
		angle = p.angle;
	}
	
	public void update()
	{
		x += Math.cos(angle - Math.PI/2.0) * speed;
		y += Math.sin(angle - Math.PI/2.0) * speed;
	}
	
	public void draw(Graphics2D g)
	{
		g.translate(x, y);
		g.rotate(angle);
		g.setColor(color);
		g.draw(bulletShape);
		g.rotate(-angle);
		g.translate(-x, -y);
	}
}
